package com.example.easy.Service.Impl;

import com.example.easy.Dto.HealthSecurity;
import com.example.easy.Dto.Notice;
import com.example.easy.Service.myservice.HealthSecurityServise;
import com.example.easy.Service.myservice.NoticeServise;
import com.example.easy.mapper.HealthSecurityMapper;
import com.example.easy.mapper.NoticeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HealthSecurityServiselmpl implements HealthSecurityServise {

    @Autowired
    HealthSecurityMapper healthSecurityMapper;

    @Override
    public int insHealthSecurity(HealthSecurity healthSecurity) {
        return healthSecurityMapper.insHealthSecurity(healthSecurity);
    }

    @Override
    public int updateHealthSecurity(HealthSecurity healthSecurity) {
        if (healthSecurityMapper.selectHealthSecurity(healthSecurity.getNumber()) != null) {
            healthSecurityMapper.updateHealthSecurity(healthSecurity);
            return 1;
        } else return 0;
    }

    @Override
    public int deleteHealthSecurity(int number) {
        if (healthSecurityMapper.selectHealthSecurity(number)!=null) {
            healthSecurityMapper.deleteHealthSecurity(number);
            return 1;
        }else return 0;
    }

    @Override
    public HealthSecurity selectHealthSecurity(int number) {
        if (healthSecurityMapper.selectHealthSecurity(number)!=null){
            return healthSecurityMapper.selectHealthSecurity(number);
        }else return null;


    }

    @Override
    public List<HealthSecurity> selectall() {
        return healthSecurityMapper.selectall();
    }
}
